package me.haoliang

/**
  * scala继承demo
  * author: planck 
  * createTime: 2016/10/13.
  */
class ExtendScala {

  var speakStr: String = _
  var temp: Int = _


  var speakFunction = () -> {
    println("father")
  }

  def this(speakStr: String, temp: Int) {
    this
    println("father constructor")
    this.speakStr = speakStr
    this.temp = temp

  }

  def speak() = {
    println(speakStr)
  }

  //必须用override修饰符修饰重写的非抽象方法
  override def toString: String = super.toString

}

class HumanSpeak(speakStr: String) extends ExtendScala(speakStr, 1) {
  override def speak = super.speak()


}

object HumanSpeak {
  def main(args: Array[String]): Unit = {
    val humanSpeak = new HumanSpeak("haha")
    humanSpeak.speakFunction
    humanSpeak.speak()
  }
}
